import { createApp } from "vue";
import App from "./App.vue";
import ElementPlus from "element-plus";
import baseComponents from "@/components";
import router from "@/router";
import store from "@/store";
import mixin from "@/mixin";
import I18n from "@/langs";
import { handleError } from "@/utils";

import "@/assets/styles/base.scss";
import "@/assets/styles/element.scss";
import "@/assets/styles/rewrite.scss";

// Global logging helpers (uncomment if needed)
// window.log = console.log;
// window.error = console.error;
// window.dir = console.dir;

const app = createApp(App);
app.config.errorHandler = handleError;
app.mixin(mixin);
app.use(ElementPlus);
app.use(baseComponents); // Register base components globally
app.use(I18n);
app.use(store);
app.use(router);
app.mount("#app");

// Only enable mock server in development mode
if (import.meta.env.MODE === "development") {
  // eslint-disable-next-line @typescript-eslint/no-var-requires
  const { setupProdMockServer } = require("flc-mock-server");
  setupProdMockServer();
}
